package com.xjtu.platform.user.assister.consultChange;

import com.xjtu.platform.common.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/assister/consultChange")
public class ConsultChangeAPI {

    @Resource
    private ConsultChangeService consultChangeService;

    @PostMapping("/getConsultInfo")
    public Result searchConsultRecord(@RequestBody ConsultChangeDto consultChangeDto){
        try {
            Map<String,Object> page = consultChangeService.getConsultRecord(consultChangeDto);
            return Result.success(page);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.fail(Result.ERR_CODE_SYS,"系统维护中.......");
        }
    }

    @PostMapping("/getFreeTime")
    public Result searchFreeTime(@RequestBody FreeTimeDto freeTimeDto){
        try {
            Map<String,Object> page = consultChangeService.getFreeTime(freeTimeDto);
            return Result.success(page);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.fail(Result.ERR_CODE_SYS,"系统维护中.......");
        }
    }

    @PostMapping("/insertTimeInfo")
    public Result insertTimeInfo(@RequestBody InsertTimeDto insertTimeDto){
        boolean ok = consultChangeService.insertTimeInfo(insertTimeDto);
        if(ok){
            return Result.success("更新成功!");
        }else {
            return Result.fail(Result.ERR_CODE_SYS,"系统维护中.......");
        }
    }
}
